找传奇、传世资源到传世资源站!

读取16进制文件程序(matplotlib)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

import sysimport osimport matplotlib.pyplot as pltimport numpy as npHexTable = {'0':0,'1':1,'2':2,'3':3,'4':4,'5':5,'6':6,'7':7,'8':8,'9':9,'A':10,'B':11,'C':12,'D':13,'E':14,'F':15}period = [0 for i in range(0,2048)]fin = open('1234.hex', 'r')i = 0for aLineData in fin: DataLen = HexTable[aLineData[1]]*16 HexTable[aLineData[2]] DataAddr = HexTable[aLineData[3]]*16*16*16 HexTable[aLineData[4]]*16*16 HexTable[aLineData[5]]*16 HexTable[aLineData[6]] DataType = HexTable[aLineData[7]]*16 HexTable[aLineData[8]] DataContent = HexTable[aLineData[9]]*16*16*16*16*16*16*16 HexTable[aLineData[10]]*16*16*16*16*16*16 HexTable[aLineData[11]]*16*16*16*16*16 HexTable[aLineData[12]]*16*16*16*16 HexTable[aLineData[13]]*16*16*16 HexTable[aLineData[14]]*16*16 HexTable[aLineData[15]]*16 HexTable[aLineData[16]] #print hex(DataLen),hex(DataAddr),hex(DataType),hex(DataContent) period[i] = DataContent i = i 1 #print(period[i])#for i in range(0,2048,1):# print("%d,"%period[i]),t = np.arange(0,2048,1) fig, ax = plt.subplots()ax.plot(t, period)ax.set(xlabel='time (s)', ylabel='frequency ', title='S-curve acceleration and deceleration')ax.grid()#fig.savefig("test.png")plt.show()fin.close()

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复